package com.ds.infra.rpc.example.butler.controller;

import com.ds.infra.rpc.annotation.RpcReference;
import com.ds.infra.rpc.example.api.WeatherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/butler")
@Slf4j
public class ButlerController {

    @RpcReference(version = "1.0", timeout = 3000)
    private WeatherService weatherService;

    @GetMapping("/weather")
    public String getTodayWeather(String city) {
        log.info("====查询 {} 天气", city);
        return weatherService.getWeather(city);
    }
}
